package demo

import (
	"fmt"
	"raymond/api/bnb"
	"raymond/global"
	"runtime"
)

var winAccts = []DemoWallet{
	{
		EthAddr:  "0xa796e8a1c7b7e1f0252df4c20f084e1527fdbc5f",
		TronAddr: "",
		Pr:       "",
	},
	{
		EthAddr:  "0x4e833ab6ed9b698d010ba1a619494c56e4a43419",
		TronAddr: "",
		Pr:       "",
	},
	{
		EthAddr:  "0xdf5b5230ec0146ec0676c3ba3bfbbbdab4c510fa",
		TronAddr: "",
		Pr:       "",
	},
}

var macAccts = []DemoWallet{
	{
		EthAddr:  "0x83C20e103a63b5a637A0140cc5825AE0B7eF5BcC",
		TronAddr: "",
		Pr:       "c72070e81fced7b7257aaa978fdd75b44bb4d55fd67f1734f4aedafa67e6105d",
	},
	{
		EthAddr:  "0x008807C67E1F9d4656838e532ddE2a24698363A5",
		TronAddr: "",
		Pr:       "6b6385010f65f32dcfce9d3251adebb9740ed710211123279a1d3b0913a09e81",
	},
	{
		EthAddr:  "0xFd0B50A876Af0f1ECeEC131ED755957147cF3eBe",
		TronAddr: "",
		Pr:       "3ab2bed8bcd2df4c3bdc0a41ee070ba2436b079260a1b48cfc6ea2c337097135",
	},
}

var testAccts = []DemoWallet{
	{
		EthAddr:  "0x07a48510445C4D33C95bF1B9859BA0F9D6941668",
		TronAddr: "TAfcpSGbvCEuch4MMPXooVEaPJ7sAVQqB2",
		Pr:       "e929e6855f0b236ea0c653d9851c4963e81990edc0f4565d2f4b9806950992b6",
	},
	{
		EthAddr:  "0x3581ab69BE6854C52C4E7339170D771C8BBBA5E2",
		TronAddr: "TEr89ptiujjR93h5wfvmMRNQbwnzYL6wp2",
		Pr:       "b35e0ff582e16a8f2e6f8acd334f2229c87dc23ce0b33423c735c969228d92a6",
	},
	{
		EthAddr:  "0xF81f894BB5D81cd1E3DaBF62c440B1508FEbEBa7",
		TronAddr: "TZ3BWn21pJEt1xuPQrwQMSJPKCL8WXiuAL",
		Pr:       "5bf8a7fb4d65a47520ec9cc8f0584261713ad2e752fbbf2650c28f238bbb7b7e",
	},
	{
		EthAddr:  "0x4f5beaba852cae03febbb992444bbb1dd5156f58",
		TronAddr: "THCpViGgBfwRoPr37RWTY93rLkq7wPRkNP",
		//Pr:       "f1f9ea0929290052d5f140d96b56d45dc0f1e215be3a7728d782e2da1c394ba7",
		Pr: "3ab2bed8bcd2df4c3bdc0a41ee070ba2436b079260a1b48cfc6ea2c337097135",
	},
}

type DemoWallet struct {
	EthAddr  string
	TronAddr string
	Pr       string
}

func GetAccount0() *DemoWallet {
	switch global.DEFAULT_ENV {
	case global.DEV:
		switch runtime.GOOS {
		case "darwin":
			return &macAccts[0]
		case "windows":
			return &winAccts[0]
		}
	}
	return &testAccts[0]
}
func GetAccount1() *DemoWallet {
	switch global.DEFAULT_ENV {
	case global.DEV:
		switch runtime.GOOS {
		case "darwin":
			return &macAccts[1]
		case "windows":
			return &winAccts[1]
		}
	}
	return &testAccts[1]
}
func GetAccount2() *DemoWallet {
	switch global.DEFAULT_ENV {
	case global.DEV:
		switch runtime.GOOS {
		case "darwin":
			return &macAccts[2]
		case "windows":
			return &winAccts[2]
		}
	}
	return &testAccts[2]
}
func GetAccount3() *DemoWallet {
	switch global.DEFAULT_ENV {
	case global.DEV:
		switch runtime.GOOS {
		case "darwin":
			return &macAccts[3]
		case "windows":
			return &winAccts[3]
		}
	}
	return &testAccts[3]
}

func GetBalance(contract string, accts ...string) {
	for _, acct := range accts {
		bal, err := bnb.GetBNBCoinBalance(acct)
		if err != nil {
			continue
		}
		val, _ := bal.Float64()
		amt := bnb.ETHER.ToWei(val)
		fmt.Printf("acct[%v] bal(wei):[%v]\n", acct, amt)
	}
}
